unit uOtliv;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, Grids, DBGridEh, StdCtrls, ImageTools;

type
  TfOtliv = class(TForm)
    GroupBox1: TGroupBox;
    DBGridEh1: TDBGridEh;
    tbOtliv: TToolBar;
    tbAddOtliv: TToolButton;
    tbDelOtliv: TToolButton;
    procedure tbAddOtlivClick(Sender: TObject);
    procedure tbDelOtlivClick(Sender: TObject);
    procedure DBGridEh1KeyPress(Sender: TObject; var Key: Char);
    procedure DBGridEh1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fOtliv: TfOtliv;

implementation

uses uDBData, uAddOtliv;

{$R *.dfm}

procedure TfOtliv.tbAddOtlivClick(Sender: TObject);
begin
  fAddOtliv.ShowModal();
  //fDBData.InsertRecord(fDBData.dOtliv);
end;

procedure TfOtliv.tbDelOtlivClick(Sender: TObject);
begin
  fDBData.DeleteRecord(fDBData.dOtliv);
end;

procedure TfOtliv.DBGridEh1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then (Sender as TDBGridEh).DataSource.DataSet.Post;
end;

procedure TfOtliv.DBGridEh1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumnEh;
  State: TGridDrawState);
begin
  if(Column.Index = 1) then
  begin
    (Sender as TDBGridEh).Canvas.Draw(Rect.Left, Rect.Top, HImageTools.GetBitmap(fDBData.dOtliv, 'OtlivImage'));
  end;
end;

end.
